package com.yanqu.road.server.cmd.vehicle;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.vehicle.VehicleProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.vehicle.VehicleModule;
import com.yanqu.road.server.protocol.GameProtocol;
import com.yanqu.road.server.protocol.Protocol;

/**
 * @Author : Cxp
 * @Time : 2024-12-23
 * @Description : 设置自动放归列表
 */

@Cmd(code = GameProtocol.S_VEHICLE_SET_AUTO_RECYCLE_LIST, desc = "设置自动放归列表")
public class VehicleSetAutoRecycleListCmd extends AbstractCommand {
    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        VehicleProto.VehicleSetAutoRecycleListReqMsg req = VehicleProto.VehicleSetAutoRecycleListReqMsg.parseFrom(packet.getBytes());

        ret = player.getModule(VehicleModule.class).setAutoRecycleList(req.getEnableAutoRecycle(), req.getVehicleIdList());
    }

    @Override
    public void sendData(GamePlayer player) {
        if (ret != 0) {
            player.sendPacket(Protocol.U_VEHICLE_SET_AUTO_RECYCLE_LIST, VehicleProto.VehicleSetAutoRecycleListRespMsg.newBuilder().setRet(ret));
        }
    }
}
